<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>快捷开发</title>
    <link rel="stylesheet" type="text/css" href="/static/hplus/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/hplus/css/style.css">
    <link rel="stylesheet" type="text/css" href="/static/layer/skin/layer.css">
    <style type="text/css">
        .clear{clear: both;}
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <h3>快捷开发</h3>
            </div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>创建验证码</h5>
                </div>
                <div class="ibox-content">
                    <div class="col-sm-3">
                        <input id="mobile" type="text" class="form-control" placeholder="手机号" autocomplete="off">
                    </div>
                    <div class="col-sm-2">
                        <input type="button" value="创建" class="btn btn-success" id="ok">
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>发送短信</h5>
                </div>
                <div class="ibox-content">
                    <div class="col-sm-3">
                        <input id="mobile2" type="text" class="form-control" placeholder="手机号" autocomplete="off">
                    </div>
                    <div class="col-sm-4">
                        <input type="button" value="发送" class="btn btn-success" id="ok2">
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="/static/hplus/js/jquery.min.js?v={php}echo time(){/php}"></script>
<script type="text/javascript" src="/static/layer/layer.js?v={php}echo time(){/php}"></script>
<script type="text/javascript">
    $(function () {
        // 创建手机验证码
        $('#ok').click(function () {
            let $mobile = $('#mobile')
            if ($mobile.val() === '') {
                layer.msg('请输入手机号', {icon: 5, time: 1000}, function () {
                    $mobile.focus()
                })
                return false
            }
            $.ajax({
                type: 'post', dataType: 'json', cache: false,
                url: '/div/create_sms_code',
                data: {'mobile': $mobile.val()},
                success: function ($data) {
                    if ($data.code === 200) {
                        layer.msg($data.message + '：' + $data.data, {icon: 1, time: 30000})
                    } else {
                        layer.msg($data.message, {icon: 2, time: 1000})
                    }
                }
            })
        })

        // 发送手机验证码
        $('#ok2').click(function () {
            let $mobile = $('#mobile2')
            if ($mobile.val() === '') {
                layer.msg('请输入手机号', {icon: 5, time: 1000}, function () {
                    $mobile.focus()
                })
                return false
            }
            $.ajax({
                type: 'post', dataType: 'json', cache: false,
                url: '/div/send_sms_code',
                data: {'mobile': $mobile.val()},
                success: function ($data) {
                    if ($data.code === 200) {
                        layer.msg($data.message, {icon: 1, time: 1000})
                    } else {
                        layer.msg($data.message, {icon: 2, time: 1000})
                    }
                }
            })
        })
    })
</script>
</html>
